/**
 *
 */
package com.googlecode.bip.entity.deprecated;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import com.googlecode.bip.entity.IQuestion;
import com.googlecode.bip.entity.ITopic;
import com.googlecode.bip.entity.Question;
import com.googlecode.bip.entity.Topic;

/**
 *
 *
 * @author Claude CHOISNET
 * @see IQuestion
 * @see Question
 * @see ITopic
 * @see Topic
 */
@Deprecated
public class Category implements Serializable
{
    private static final long serialVersionUID = 1L;

    private int idcategory;
    private String idlocal;
    private String name;
    private String description;
    private int parentidcategory;
    private int categorylevel;
    private int order;
    private int minvalue;
    private int maxvalue;
    private int defaultvalue;
    private int isactive = Integer.MIN_VALUE; // TODO ! Views not able to handle for now

    /** Optional value */
    private Integer iduser;
    /** Optional value */
    private Integer uservalue;
    /** Optional value */
    private Timestamp userdate;

    /** Optional value */
    private String usercomment;
    /** Optional value */
    private String valuedescription;

    /**
     * Create a NOT initialized Category
     */
    public Category()
    {
    }

    /**
     * Create a shadow copy of giving Category
     *
     * @param c Category to clone
     */
    public Category( final Category c )
    {
        this.idcategory         = c.idcategory;
        this.idlocal            = c.idlocal;
        this.name               = c.name;
        this.description        = c.description;
        this.parentidcategory   = c.parentidcategory;
        this.categorylevel      = c.categorylevel;
        this.order              = c.order;
        this.minvalue           = c.minvalue;
        this.maxvalue           = c.maxvalue;
        this.defaultvalue       = c.defaultvalue;
        this.isactive           = c.isactive;

        /** Optional values */
        this.iduser             = c.iduser;
        this.uservalue          = c.uservalue;
        this.userdate           = c.userdate;
        this.usercomment        = c.usercomment;
        this.valuedescription   = c.valuedescription;
    }

    public Category set( final ResultSet rSet ) throws SQLException
    {
        idcategory          = rSet.getInt( "idcategory" );
        idlocal             = rSet.getString( "idlocal" );
        name                = rSet.getString( "categoryname" );
        description         = rSet.getString( "categorydescription" );
        parentidcategory    = rSet.getInt( "parentidcategory" );
        categorylevel       = rSet.getInt( "categorylevel" );
        order               = rSet.getInt( "order" );
        minvalue            = rSet.getInt( "minvalue" );
        maxvalue            = rSet.getInt( "maxvalue" );
        defaultvalue        = rSet.getInt( "defaultvalue" );
        //TODO isactive            =  rSet.getInt( "isactive" );

        try {
            iduser = rSet.getInt( "iduser" );
            }
        catch( SQLException e ) {
            iduser = null;
            }
        if( iduser != null ) {
            // Found 'iduser', so get informations for this value
            uservalue = rSet.getInt( "uservalue" );
            usercomment         = rSet.getString( "usercomment" );
            valuedescription    = rSet.getString( "valuedescription" );
            userdate            = rSet.getTimestamp( "userdate" );
            }
        else {
            uservalue = null;
            usercomment = valuedescription = null;
            userdate = null;
        }

        return this;
    }

    /**
     * @return the parentidcategory
     */
    public int getParentidcategory()
    {
        return parentidcategory;
    }

    /**
     * @param parentidcategory the parentidcategory to set
     */
    public void setParentidcategory( int parentidcategory )
    {
        this.parentidcategory = parentidcategory;
    }

    /**
     * @return the idcategory
     */
    public int getIdcategory()
    {
        return idcategory;
    }

    /**
     * @param idcategory the idcategory to set
     */
    public void setIdcategory( int idcategory )
    {
        this.idcategory = idcategory;
    }

    /**
     * @return the idlocal
     */
    public String getIdlocal()
    {
        return idlocal;
    }

    /**
     * @param idlocal the idlocal to set
     */
    public void setIdlocal( String idlocal )
    {
        this.idlocal = idlocal;
    }

    /**
     * Get the category name/label (max length 64)
     * @return the name
     */
    public String getName()
    {
        return name;
    }

    /**
     * Set the category name/label (max length 64)
     * @param name the name to set
     */
    public void setName( String name )
    {
        this.name = name;
    }

    /**
     * Get the category description (max length 255 - HTML formatted)
     * @return the description
     */
    public String getDescription()
    {
        return description;
    }

    /**
     * Set the category description (max length 255 - HTML formatted)
     * @param description the description to set
     */
    public void setDescription( String description )
    {
        this.description = description;
    }

    /**
     * IGNORE THIS
     * @return the categorylevel
     */
    @Deprecated
    public int getCategorylevel()
    {
        return categorylevel;
    }

    /**
     * IGNORE THIS
     * @param categorylevel the categorylevel to set
     */
    @Deprecated
    public void setCategorylevel( int categorylevel )
    {
        this.categorylevel = categorylevel;
    }

    /**
     * Returns the display order when display a Category list.
     * @return the display order
     */
    public int getOrder()
    {
        return order;
    }

    /**
     * Set the display order when display a Category list.
     * @param order the order to set
     */
    public void setOrder( int order )
    {
        this.order = order;
    }

    /**
     * @return the minvalue
     */
    public int getMinvalue()
    {
        return minvalue;
    }

    /**
     * @param minvalue the minvalue to set
     */
    public void setMinvalue( int minvalue )
    {
        this.minvalue = minvalue;
    }

    /**
     * @return the maxvalue
     */
    public int getMaxvalue()
    {
        return maxvalue;
    }

    /**
     * @param maxvalue the maxvalue to set
     */
    public void setMaxvalue( int maxvalue )
    {
        this.maxvalue = maxvalue;
    }

    /**
     * @return the isactive
     */
    public int getIsactive()
    {
        return isactive;
    }

    /**
     * @param isactive the isactive to set
     */
    public void setIsactive( int isactive )
    {
        this.isactive = isactive;
    }

    // ----------------------------------------------------------
    // Optional
    // ----------------------------------------------------------

    /**
     * Optional value
     * @return the iduser
     */
    public Integer getIduser()
    {
        return iduser;
    }

    /**
     * Optional value
     * @param iduser the iduser to set
     */
    public void setIduser( Integer iduser )
    {
        this.iduser = iduser;
    }

    /**
     * Optional value
     * @return the uservalue
     */
    public Integer getUservalue()
    {
        return uservalue;
    }

    /**
     * Optional value
     * @param uservalue the uservalue to set
     */
    public void setUservalue( Integer uservalue )
    {
        this.uservalue = uservalue;
    }

    /**
     * Optional value
     * @return the usercomment
     */
    public String getUsercomment()
    {
        if( usercomment == null ) {
            return "";
        }
        return usercomment;
    }

    /**
     * Optional value
     * @param usercomment the usercomment to set
     */
    public void setUsercomment( String usercomment )
    {
        this.usercomment = usercomment;
    }

    /**
     * Optional value
     * @return the uservaluedescription
     */
    public String getValuedescription()
    {
        return valuedescription;
    }

    /**
     * Optional value
     * @param uservaluedescription the valuedescription to set
     */
    public void setValuedescription( String valuedescription )
    {
        this.valuedescription = valuedescription;
    }

    /**
     * Optional value
     * @return the userdate
     */
    public Timestamp getUserdate()
    {
        return userdate;
    }

    /**
     * Optional value
     * @param userdate the userdate to set
     */
    public void setUserdate( Timestamp userdate )
    {
        this.userdate = userdate;
    }

    /**
     * Optional value
     * @return the defaultvalue
     */
    public int getDefaultvalue()
    {
        return defaultvalue;
    }

    /**
     * Optional value
     * @param defaultvalue the defaultvalue to set
     */
    public void setDefaultvalue( int defaultvalue )
    {
        this.defaultvalue = defaultvalue;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString()
    {
        StringBuilder builder = new StringBuilder();
        builder.append( "Category [idcategory=" );
        builder.append( idcategory );
        builder.append( ", idlocal=" );
        builder.append( idlocal );
        builder.append( ", name=" );
        builder.append( name );
        builder.append( ", description=" );
        builder.append( description );
        builder.append( ", parentidcategory=" );
        builder.append( parentidcategory );
        builder.append( ", categorylevel=" );
        builder.append( categorylevel );
        builder.append( ", order=" );
        builder.append( order );
        builder.append( ", minvalue=" );
        builder.append( minvalue );
        builder.append( ", maxvalue=" );
        builder.append( maxvalue );
        builder.append( ", defaultvalue=" );
        builder.append( defaultvalue );
        builder.append( ", iduser=" );
        builder.append( iduser );
        builder.append( ", uservalue=" );
        builder.append( uservalue );
        builder.append( ", userdate=" );
        builder.append( userdate );
        builder.append( ", usercomment=" );
        builder.append( usercomment );
        builder.append( ", valuedescription=" );
        builder.append( valuedescription );
        builder.append( "]" );
        return builder.toString();
    }

}
